var express = require('express');
var router = express.Router();
var fs = require('fs');

/* GET download tar file. */
router.get('/download', function (req, res, next) {
    var id = req.query.id || '';
    var filePath = '/tmp/' + id + '.tar';
    var filename = id + '.tar';
    if (fs.existsSync(filePath))
        res.download(filePath, filename);
    else
        next();
});

module.exports = router;
